import { Request } from "./request";

// 登录
export const login = ruleForm =>
  Request.getData({
    url: `/api/manage/user/login.do?username=${ruleForm.username}&password=${ruleForm.password}`,
    method: "post"
  });

// 首页
export const getHome = () =>
  Request.getData({
    url: "/api/manage/statistic/base_count.do"
  });

// 用户管理
export const userlist = pageNum =>
  Request.getData({
    url: `/api/manage/user/list.do?pageNum=${pageNum}`,
    method: "post"
  });

// 商品管理
export const goods = pageNum =>
  Request.getData({
    url: `/api/manage/product/list.do?pageNum=${pageNum}`
  });

// 订单管理

export const order = pageNum =>
  Request.getData({
    url: `/api/manage/order/list.do?pageNum=${pageNum}`
  });

// 订单详情
export const orderdetail = orderNo =>
  Request.getData({
    url: `/api/manage/order/detail.do?orderNo=${orderNo}`
  });

export const hhh = id =>
  Request.getData({
    url: `/api/manage/category/get_category.do?categoryId=${id}`
  });

// /manage/order/search.do?listType=search&pageNum=1&orderNo=1615621949249

export const orderSearch = id =>
  Request.getData({
    url: `/api/manage/order/search.do?listType=search&pageNum=1&orderNo=${id}`
  });

// 品类管理

export const kind = id =>
  Request.getData({
    url: `/api/manage/category/get_category.do?categoryId=${id}`
  });

// 更改品类名称

export const kindName = (id, name) =>
  Request.getData({
    url: `/api/manage/category/set_category_name.do?categoryId=${id}&categoryName=${name}`
  });

// 添加品类

export const kindAdd = (parentId, categoryName) =>
  Request.getData({
    url: `/api/manage/category/add_category.do?parentId=${parentId}&categoryName=${categoryName}`
  });

// 按照商品名称查询

export const shopName = productname =>
  Request.getData({
    url: `/api/manage/product/search.do?listType=search&pageNum=1&productName=${productname}`
  });

export const shopId = productId =>
  Request.getData({
    url: `/api/manage/product/search.do?listType=search&pageNum=1&productId=${productId}`
  });

export const changestatus = (id, status) =>
  Request.getData({
    url: `/api/manage/product/set_sale_status.do?productId=${id}&status=${status}`
  });

export const detail = id =>
  Request.getData({
    url: `/api/manage/product/detail.do?productId=${id}`
  });

export const addlist = obj =>
  Request.getData({
    url: `/api/manage/product/save.do?categoryId=${obj.categoryId}&name=${obj.name}&subtitle=${obj.subtitle}&subImages=${obj.imgs}&detail=${obj.detail}&price=${obj.price}&stock=${obj.stock}&status=${obj.status}`,
    method: "post"
  });

export const fenlei = () =>
  Request.getData({
    url: `/api/manage/category/get_category.do?categoryId=0`
  });

export const er = id =>
  Request.getData({
    url: `/api/manage/category/get_category.do?categoryId=${id}`
  });

export const toGoodsDetails = categoryId =>
  Request.getData({
    url: `/api/manage/product/detail.do?productId=${categoryId}`
  });

export const editGoods = (
  categoryId,
  name,
  subtitle,
  img,
  detail,
  price,
  stock,
  status,
  id
) =>
  Request.getData({
    url: `/api/manage/product/save.do?categoryId=${categoryId}&name=${name}&subtitle=${subtitle}&subImages=${img}&detail=${detail}&price=${price}&stock=${stock}&status=${status}&id=${id}`
  });
